import datetime
from haystack import indexes
from .models import Product

class ProductIndex(indexes.SearchIndex, indexes.Indexable):
	text=indexes.CharField(document=True, use_template=True)
	name=indexes.CharField(model_attr='name')
	website=indexes.CharField(model_attr='website')
	category=indexes.CharField(model_attr='category')
	update_date=indexes.DateTimeField(model_attr='update_date')
	
	def get_model(self):
		return Product
	
	def index_queryset(self, using=None):
		return self.get_model().objects.order_by('-update_date')